package com.examples.controller;

import com.examples.Mapper.UserMapper;
import com.examples.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
@Autowired

private UserMapper userMapper;
@GetMapping("/queryUserList")
public List<User>queryUserList(){
List<User>Lists=userMapper.queryList();
for (User user:Lists)
{
    System.out.println(user);

}
 return Lists;
}

@GetMapping("/addUser/{id}/{department_name}")
    public String addUser(@PathVariable int id, @PathVariable String department_name){
    userMapper.addUser(new User(id,department_name));
    return "ok";
}
}
